package com.matt.domain.statistics;

import com.matt.foundation.model.Domain;
import com.matt.foundation.utils.DateUtil;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;

/**
 * *******************************
 * Created by Ron.
 * form com.matt
 * on 2018/7/3
 * leads统计
 * *******************************
 */
@Data
@Entity
@Table(name = "stat_leads")
@EqualsAndHashCode(callSuper = true)
public class StatLeads extends Domain {

    @Column(columnDefinition = "varchar(32) COMMENT '对应leads id'")
    private String leadsId;

    @Column(columnDefinition = "int default 1 COMMENT '类型：1，创建，2，变为已到访，3。已成交'")
    private Integer type = 1;

    @Column(columnDefinition = "int  COMMENT '类型：1，主动，2，被动'")
    private Integer category;

    @Column(columnDefinition = "varchar(32) COMMENT '对应员工id'")
    private String staffId;

    @Column(columnDefinition = "varchar(32) COMMENT '渠道id'")
    private String channelId;

    @Column(columnDefinition = "varchar(32) COMMENT '对应园区 id'")
    private String areaId;

    public static StatLeads of(String leadsId, Integer type, Integer category, String channelId, String areaId, String staffId, Date date) {
        StatLeads leads = new StatLeads();
        leads.setAreaId(areaId);
        leads.setType(type);
        leads.setCategory(category);
        leads.setChannelId(channelId);
        leads.setLeadsId(leadsId);
        leads.setStaffId(staffId);
        leads.setCreated(date);
        return leads;
    }

    public StatLeads transfer(String staffId) {
        this.setStaffId(staffId);
        return this;
    }
}
